<template>
  <div>
    <div>
      <textarea id="" cols="30" rows="10" v-model="text"> </textarea>
      <button @click="sendText">发送</button>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name:'TextEdit',
  props: ['word','content'],
  data() {
    return {
      text:this.content
    }
  },
  methods: {
    sendText(){
      const requireA = axios.create({
        baseURL: "",
      });
      var post_info = {
        account: this.$store.state.userName,
        word:this.word,
        content:this.text,
        token:this.$store.state.token
      };
      requireA({
        url: "/apiTextChange",
        method: "POST",
        data: post_info,
      }).catch(function (error) {
        if (error.response) {
          console.log('登录请求失败',error.response.status);
        } else {
          console.log('Error', error.message);
          console.log(error.config);
        }
      }).then((res)=>{
        if (!res){
          return
        }
        if (res['data']=='Send Ok') {
          window.alert('编辑成功');
        }else{
          // console.log(res['data'],'response',typeof( res['data']));
          window.alert(res['data']);
        }
      });
    },
  },
}
</script>

<style scoped>
</style>